Make realize and unrealize signals. (#73310)
authorOwen Taylor <otaylor@redhat.com>
Wed, 25 Feb 2004 18:03:12 +0000 (18:03 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 25 Feb 2004 18:03:12 +0000 (18:03 +0000)
Wed Feb 25 12:44:49 2004  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkstyle.[ch]: Make realize and unrealize signals. (#73310)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkstyle.c

index 98d9a051b1e15ca8a6c7687e7c6deb953aced7c9..9265714da35e1a2a1f5c6d4943ea57e4c7f8c886 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Feb 25 12:44:49 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.[ch]: Make realize and unrealize signals. (#73310)
+
 Wed Feb 25 12:21:32 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.[ch] gtk/gtklabel.c: Patch from
index 98d9a051b1e15ca8a6c7687e7c6deb953aced7c9..9265714da35e1a2a1f5c6d4943ea57e4c7f8c886 100644 (file)
@@ -1,3 +1,7 @@
+Wed Feb 25 12:44:49 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.[ch]: Make realize and unrealize signals. (#73310)
+
 Wed Feb 25 12:21:32 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.[ch] gtk/gtklabel.c: Patch from
index 98d9a051b1e15ca8a6c7687e7c6deb953aced7c9..9265714da35e1a2a1f5c6d4943ea57e4c7f8c886 100644 (file)
@@ -1,3 +1,7 @@
+Wed Feb 25 12:44:49 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.[ch]: Make realize and unrealize signals. (#73310)
+
 Wed Feb 25 12:21:32 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.[ch] gtk/gtklabel.c: Patch from
index 98d9a051b1e15ca8a6c7687e7c6deb953aced7c9..9265714da35e1a2a1f5c6d4943ea57e4c7f8c886 100644 (file)
@@ -1,3 +1,7 @@
+Wed Feb 25 12:44:49 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.[ch]: Make realize and unrealize signals. (#73310)
+
 Wed Feb 25 12:21:32 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.[ch] gtk/gtklabel.c: Patch from
index 98d9a051b1e15ca8a6c7687e7c6deb953aced7c9..9265714da35e1a2a1f5c6d4943ea57e4c7f8c886 100644 (file)
@@ -1,3 +1,7 @@
+Wed Feb 25 12:44:49 2004  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.[ch]: Make realize and unrealize signals. (#73310)
+
 Wed Feb 25 12:21:32 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwidget.[ch] gtk/gtklabel.c: Patch from
index 7236d98f4897ae5464cec0b7b8e3234554d96826..e66e32f6dbad12898f3082d1e4aee4daab5714e4 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "gtkgc.h"
+#include "gtkmarshalers.h"
 #include "gtkrc.h"
 #include "gtkspinbutton.h"
 #include "gtkstyle.h"
@@ -462,6 +463,9 @@ static const GdkColor gtk_default_active_base =    { 0, 0x8080, 0x7d7d, 0x7474 }
 
 static gpointer parent_class = NULL;
 
+/* --- signals --- */
+static guint realize_signal = 0;
+static guint unrealize_signal = 0;
 
 /* --- functions --- */
 GType
@@ -640,6 +644,40 @@ gtk_style_class_init (GtkStyleClass *klass)
   klass->draw_expander = gtk_default_draw_expander;
   klass->draw_layout = gtk_default_draw_layout;
   klass->draw_resize_grip = gtk_default_draw_resize_grip;
+
+  
+  /**
+   * GtkStyle::realize:
+   * @style: the object which received the signal
+   *
+   * Emitted when the style has been initialized for a particular
+   * colormap and depth. Connecting to this signal is probably seldom
+   * useful since most of the time applications and widgets only
+   * deal with styles that have been already realized.
+   */
+  realize_signal = g_signal_new ("realize",
+                                G_TYPE_FROM_CLASS (object_class),
+                                G_SIGNAL_RUN_FIRST,
+                                G_STRUCT_OFFSET (GtkStyleClass, realize),
+                                NULL, NULL,
+                                _gtk_marshal_VOID__VOID,
+                                G_TYPE_NONE, 0);
+  /**
+   * GtkStyle::unrealize:
+   * @style: the object which received the signal
+   *
+   * Emitted when the aspects of the style specific to a particular colormap
+   * and depth are being cleaned up. A connection to this signal can be useful
+   * if a widget wants to cache objects like a #GdkGC as object data on #GtkStyle.
+   * This signal provides a convenient place to free such cached objects.
+   */
+  unrealize_signal = g_signal_new ("unrealize",
+                                  G_TYPE_FROM_CLASS (object_class),
+                                  G_SIGNAL_RUN_FIRST,
+                                  G_STRUCT_OFFSET (GtkStyleClass, unrealize),
+                                  NULL, NULL,
+                                  _gtk_marshal_VOID__VOID,
+                                  G_TYPE_NONE, 0);
 }
 
 static void
@@ -859,7 +897,7 @@ gtk_style_detach (GtkStyle *style)
   style->attach_count -= 1;
   if (style->attach_count == 0)
     {
-      GTK_STYLE_GET_CLASS (style)->unrealize (style);
+      g_signal_emit (style, unrealize_signal, 0);
       
       g_object_unref (style->colormap);
       style->colormap = NULL;
@@ -915,7 +953,7 @@ gtk_style_realize (GtkStyle    *style,
   style->colormap = g_object_ref (colormap);
   style->depth = gdk_colormap_get_visual (colormap)->depth;
 
-  GTK_STYLE_GET_CLASS (style)->realize (style);
+  g_signal_emit (style, realize_signal, 0);
 }
 
 GtkIconSet*